<?php $this->load->view('layout/header_data_form');?>
<script>
function get_paid()
{
	$.ajax({
		   type: "POST",
		   url: "<?php echo base_url().'srs/get_paid'?>",
		   data: "value="+$("#textfield5").val(),
		   success: function(msg){
		     $('#paid').val(msg);
		     $('#hpaid').val(msg);
		   }
	});
}
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><h1>SRS</h1></td>
    <td align="right"><img src=<?php echo img_link("small-logo.gif");?> width="147" height="38" /></td>
  </tr>
</table>
<div id="wrap">
  <form id="form1" name="form1" method="post" action="">
    <table border="0" cellpadding="5" cellspacing="0">
      <tr>
        <td width="500" align="left" valign="top"><table border="0" cellpadding="7" cellspacing="0">
          <tr>
            <td align="right"><strong>Accessible  Income for <br />
              Previous Year:</strong></td>
            <td><input onblur="get_paid()" value="<?php echo ($row ? $row["accessible_income_previous_year"] : "")?>" name="textfield5" type="text" class="field" id="textfield5" size="40" /></td>
          </tr>

          <tr>
            <td align="right"><strong>Income tax paid:</strong></td>
            <td>
            <input disabled="disabled" value="<?php echo ($row ? $row["income_tax_paid"] : "")?>" name="textfield2" type="text" class="field" id="paid" size="40" />
            <input type="hidden" name="hpaid" id="hpaid"/>
            </td>
          </tr>
          <tr>
            <td align="right"><strong>With SRS:</strong></td>
            <td><input value="<?php echo ($row ? $row["with_srs"] : "")?>" name="textfield6" type="text" class="field" id="textfield6" size="40" /></td>
          </tr>
</table>
<br />
<br />
<input name="btnCalculate" class="large button green" type="submit" value="Calculate"/>

<div id="graph" style="">
<br />
<br />
 
 
 <input type="hidden" value="0" id="submit" name="submit" />
 <?php //if($row && $_POST):?>
 <?php $this->load->view('srs/chart');?>
     <input type="hidden" value="1" id="submit" name="submit" />
            <table border="0" cellpadding="7" cellspacing="0">
              <tr>
                <td align="left"><strong>Explanation:</strong></td>
              </tr>
              <tr>
                <td align="left"><textarea name="textfield3" cols="60" rows="6" class="field" id="textfield3"><?php echo ($row && isset($row["explanation"]) ? $row["explanation"] : "")?></textarea></td>
              </tr>
              <tr>
                <td align="right"><input name="btnSubmit" type="submit" class="large button red" value="Submit" /></td>
              </tr>
          </table>
</form>
<?php //endif;?>
<br />
</div>
<br />
  <a href="JavaScript:window.close();"><img src="<?php echo img_link('cwindow.jpg');?>" alt="Close Window" width="82" height="15" border="0" /></a>
</td>
<td align="left" valign="top">
        
        <div id="result" style="display:<?php echo ($row ? 'block' : 'block');?>">
        <?php 
        	
        	$YI=0;$SRS=0;$temp=0;$total=0;
        	$YI		=	intval($row['accessible_income_previous_year']);	
        	$SRS	=	intval($row['with_srs']);
        	$temp	=	$YI - $SRS;
        	
        	$T1 = tinh_src($YI);
        	//echo $T1;
        	$T2 = tinh_src($temp);
        	//echo $T2;
        	$total = $T1 - $T2;
        	
        	
        ?>
        <table border="0" cellpadding="5" cellspacing="0">
          <tr>
            <td align="left" valign="top"><strong>Saving:</strong></td>
            <td align="left" valign="top"><span class="red-text">S$<?php echo $total;?></span></td>
          </tr>
        </table>
        </div>
        
        </td>
</tr>
</table>
<?php $this->load->view('layout/footer_data_form');?>